home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ccrptmr / fnotify.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-11  |  10.4 KB  |  332 lines

  1. VERSION 5.00
  2. Begin VB.Form FNotify 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4425
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5175
  8.    Icon            =   "FNotify.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4425
  11.    ScaleWidth      =   5175
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Frame Frame3 
  14.       Caption         =   "Intrinsic Timer:"
  15.       Height          =   795
  16.       Left            =   120
  17.       TabIndex        =   17
  18.       Top             =   3000
  19.       Width           =   4935
  20.       Begin VB.Timer tmrClassic 
  21.          Left            =   4440
  22.          Top             =   240
  23.       End
  24.       Begin VB.CheckBox chkEvent 
  25.          Caption         =   "Enabled"
  26.          Height          =   255
  27.          Index           =   2
  28.          Left            =   3360
  29.          TabIndex        =   18
  30.          Top             =   360
  31.          Width           =   1395
  32.       End
  33.       Begin VB.Label Label1 
  34.          Alignment       =   1  'Right Justify
  35.          AutoSize        =   -1  'True
  36.          Caption         =   "Classic Event Method:"
  37.          Height          =   195
  38.          Index           =   4
  39.          Left            =   180
  40.          TabIndex        =   20
  41.          Top             =   360
  42.          Width           =   1590
  43.       End
  44.       Begin VB.Label lblEvent 
  45.          BorderStyle     =   1  'Fixed Single
  46.          Caption         =   "lblEvent"
  47.          Height          =   315
  48.          Index           =   2
  49.          Left            =   1920
  50.          TabIndex        =   19
  51.          Top             =   300
  52.          Width           =   1215
  53.       End
  54.    End
  55.    Begin VB.CommandButton cmdAbout 
  56.       Cancel          =   -1  'True
  57.       Caption         =   "&About"
  58.       Height          =   375
  59.       Left            =   1860
  60.       TabIndex        =   16
  61.       Top             =   3960
  62.       Width           =   1455
  63.    End
  64.    Begin VB.Frame Frame2 
  65.       Caption         =   "Implements ICcrpCountdownNotify:"
  66.       Height          =   1275
  67.       Left            =   120
  68.       TabIndex        =   9
  69.       Top             =   1560
  70.       Width           =   4935
  71.       Begin VB.CheckBox chkNotify 
  72.          Caption         =   "Enabled"
  73.          Height          =   255
  74.          Index           =   1
  75.          Left            =   3360
  76.          TabIndex        =   11
  77.          Top             =   780
  78.          Width           =   1395
  79.       End
  80.       Begin VB.CheckBox chkEvent 
  81.          Caption         =   "Enabled"
  82.          Height          =   255
  83.          Index           =   1
  84.          Left            =   3360
  85.          TabIndex        =   10
  86.          Top             =   420
  87.          Width           =   1395
  88.       End
  89.       Begin VB.Label lblNotify 
  90.          BorderStyle     =   1  'Fixed Single
  91.          Caption         =   "lblNotify"
  92.          Height          =   315
  93.          Index           =   1
  94.          Left            =   1920
  95.          TabIndex        =   15
  96.          Top             =   780
  97.          Width           =   1215
  98.       End
  99.       Begin VB.Label lblEvent 
  100.          BorderStyle     =   1  'Fixed Single
  101.          Caption         =   "lblEvent"
  102.          Height          =   315
  103.          Index           =   1
  104.          Left            =   1920
  105.          TabIndex        =   14
  106.          Top             =   360
  107.          Width           =   1215
  108.       End
  109.       Begin VB.Label Label1 
  110.          Alignment       =   1  'Right Justify
  111.          AutoSize        =   -1  'True
  112.          Caption         =   "Notification Method:"
  113.          Height          =   195
  114.          Index           =   3
  115.          Left            =   345
  116.          TabIndex        =   13
  117.          Top             =   840
  118.          Width           =   1425
  119.       End
  120.       Begin VB.Label Label1 
  121.          Alignment       =   1  'Right Justify
  122.          AutoSize        =   -1  'True
  123.          Caption         =   "Classic Event Method:"
  124.          Height          =   195
  125.          Index           =   2
  126.          Left            =   180
  127.          TabIndex        =   12
  128.          Top             =   420
  129.          Width           =   1590
  130.       End
  131.    End
  132.    Begin VB.Frame Frame1 
  133.       Caption         =   "Implements ICcrpTimerNotify:"
  134.       Height          =   1275
  135.       Left            =   120
  136.       TabIndex        =   0
  137.       Top             =   120
  138.       Width           =   4935
  139.       Begin VB.CheckBox chkEvent 
  140.          Caption         =   "Enabled"
  141.          Height          =   255
  142.          Index           =   0
  143.          Left            =   3360
  144.          TabIndex        =   3
  145.          Top             =   420
  146.          Width           =   1395
  147.       End
  148.       Begin VB.CheckBox chkNotify 
  149.          Caption         =   "Enabled"
  150.          Height          =   255
  151.          Index           =   0
  152.          Left            =   3360
  153.          TabIndex        =   6
  154.          Top             =   780
  155.          Width           =   1395
  156.       End
  157.       Begin VB.Label Label1 
  158.          Alignment       =   1  'Right Justify
  159.          AutoSize        =   -1  'True
  160.          Caption         =   "Classic Event Method:"
  161.          Height          =   195
  162.          Index           =   0
  163.          Left            =   180
  164.          TabIndex        =   1
  165.          Top             =   420
  166.          Width           =   1590
  167.       End
  168.       Begin VB.Label Label1 
  169.          Alignment       =   1  'Right Justify
  170.          AutoSize        =   -1  'True
  171.          Caption         =   "Notification Method:"
  172.          Height          =   195
  173.          Index           =   1
  174.          Left            =   345
  175.          TabIndex        =   4
  176.          Top             =   840
  177.          Width           =   1425
  178.       End
  179.       Begin VB.Label lblEvent 
  180.          BorderStyle     =   1  'Fixed Single
  181.          Caption         =   "lblEvent"
  182.          Height          =   315
  183.          Index           =   0
  184.          Left            =   1920
  185.          TabIndex        =   2
  186.          Top             =   360
  187.          Width           =   1215
  188.       End
  189.       Begin VB.Label lblNotify 
  190.          BorderStyle     =   1  'Fixed Single
  191.          Caption         =   "lblNotify"
  192.          Height          =   315
  193.          Index           =   0
  194.          Left            =   1920
  195.          TabIndex        =   5
  196.          Top             =   780
  197.          Width           =   1215
  198.       End
  199.    End
  200.    Begin VB.CommandButton cmdExit 
  201.       Caption         =   "E&xit"
  202.       Height          =   375
  203.       Left            =   3480
  204.       TabIndex        =   8
  205.       Top             =   3960
  206.       Width           =   1455
  207.    End
  208.    Begin VB.CommandButton cmdBlock 
  209.       Caption         =   "Test &Blocking"
  210.       Height          =   375
  211.       Left            =   240
  212.       TabIndex        =   7
  213.       Top             =   3960
  214.       Width           =   1455
  215.    End
  216. Attribute VB_Name = "FNotify"
  217. Attribute VB_GlobalNameSpace = False
  218. Attribute VB_Creatable = False
  219. Attribute VB_PredeclaredId = True
  220. Attribute VB_Exposed = False
  221. Option Explicit
  222. Implements ICcrpTimerNotify
  223. Private tmrNotify As ccrpTimer
  224. Private WithEvents tmrEvent As ccrpTimer
  225. Attribute tmrEvent.VB_VarHelpID = -1
  226. Implements ICcrpCountdownNotify
  227. Private cntNotify As ccrpCountdown
  228. Private WithEvents cntEvent As ccrpCountdown
  229. Attribute cntEvent.VB_VarHelpID = -1
  230. Private tmrStopWatch As ccrpStopWatch
  231. Const nTmr = 0
  232. Const nCnt = 1
  233. Const nVb = 2
  234. Private Sub chkEvent_Click(Index As Integer)
  235.    If Index = nTmr Then
  236.       tmrEvent.Enabled = CBool(chkEvent(Index).Value)
  237.    ElseIf Index = nCnt Then
  238.       cntEvent.Enabled = CBool(chkEvent(Index).Value)
  239.    ElseIf Index = nVb Then
  240.       tmrClassic.Enabled = CBool(chkEvent(Index).Value)
  241.    End If
  242. End Sub
  243. Private Sub chkNotify_Click(Index As Integer)
  244.    If Index = nTmr Then
  245.       tmrNotify.Enabled = CBool(chkNotify(Index).Value)
  246.    Else
  247.       cntNotify.Enabled = CBool(chkNotify(Index).Value)
  248.    End If
  249. End Sub
  250. Private Sub cmdAbout_Click()
  251.    tmrNotify.About
  252. End Sub
  253. Private Sub cmdBlock_Click()
  254.    MsgBox "This MsgBox should block the Event driven timers, " & vbCrLf & _
  255.           "but only within the IDE."
  256. End Sub
  257. Private Sub cmdExit_Click()
  258.    Unload Me
  259. End Sub
  260. Private Sub cntEvent_Tick(ByVal TimeRemaining As Long)
  261.    lblEvent(nCnt).Caption = " " & Format(TimeRemaining / 1000, "0.0") & " sec"
  262. End Sub
  263. Private Sub cntEvent_Timer()
  264.    chkEvent(nCnt).Value = vbUnchecked
  265.    lblEvent(nCnt).Caption = " Done!"
  266. End Sub
  267. Private Sub Form_Load()
  268.    Set tmrNotify = New ccrpTimer
  269.    With tmrNotify
  270.       .EventType = TimerPeriodic
  271.       .Interval = 100
  272.       Set .Notify = Me
  273.       .Stats.Frequency = 10
  274.    End With
  275.    Set tmrEvent = New ccrpTimer
  276.    With tmrEvent
  277.       .EventType = TimerPeriodic
  278.       .Interval = 100
  279.    End With
  280.    Set cntNotify = New ccrpCountdown
  281.    With cntNotify
  282.       .Duration = 20000
  283.       .Interval = 100
  284.       Set .Notify = Me
  285.    End With
  286.    Set cntEvent = New ccrpCountdown
  287.    With cntEvent
  288.       .Duration = 20000
  289.       .Interval = 100
  290.    End With
  291.    With tmrClassic
  292.       .Interval = 100
  293.    End With
  294.    Set tmrStopWatch = New ccrpStopWatch
  295.    Me.Caption = "Implemented Timer Notification Demo"
  296.    lblEvent(nCnt).Caption = ""
  297.    lblNotify(nCnt).Caption = ""
  298.    chkEvent(nTmr).Value = vbChecked
  299.    chkNotify(nTmr).Value = vbChecked
  300.    chkEvent(nVb).Value = vbChecked
  301. End Sub
  302. Private Sub Form_Unload(Cancel As Integer)
  303.    tmrEvent.Enabled = False
  304.    Set tmrEvent = Nothing
  305.    tmrNotify.Enabled = False
  306.    Set tmrNotify = Nothing
  307.    cntEvent.Enabled = False
  308.    Set cntEvent = Nothing
  309.    cntNotify.Enabled = False
  310.    Set cntNotify = Nothing
  311. End Sub
  312. Private Sub ICcrpCountdownNotify_Tick(ByVal TimeRemaining As Long)
  313.    lblNotify(nCnt).Caption = " " & Format(TimeRemaining / 1000, "0.0") & " sec"
  314. End Sub
  315. Private Sub ICcrpCountdownNotify_Timer()
  316.    chkNotify(nCnt).Value = vbUnchecked
  317.    lblNotify(nCnt).Caption = " Done!"
  318. End Sub
  319. Private Sub ICcrpTimerNotify_Timer(ByVal Milliseconds As Long)
  320.    Static Ticks As Long
  321.    Ticks = Ticks + Milliseconds
  322.    lblNotify(nTmr).Caption = " " & Format(Ticks, "#,##0")
  323. End Sub
  324. Private Sub tmrClassic_Timer()
  325.    lblEvent(nVb).Caption = " " & Format(tmrStopWatch.Elapsed, "#,##0")
  326. End Sub
  327. Private Sub tmrEvent_Timer(ByVal Milliseconds As Long)
  328.    Static Ticks As Long
  329.    Ticks = Ticks + Milliseconds
  330.    lblEvent(nTmr).Caption = " " & Format(Ticks, "#,##0")
  331. End Sub
  332.